<!--
 * @Description: 培训日志表
 * @Autor: dyx
 * @Date: 2023-05-31 17:36:40
 * @LastEditTime: 2023-06-02 11:12:22
-->

<template>
  <div class="TISchedule">
    <div style="padding-right: 7px;">
      <el-button type="primary" style="float:right" @click="exportWord"
        >导出Word</el-button
      >
    </div>
    <div class="mytable" v-loading="loading">
      <div class="table_title">培训日志表</div>
      <table>
        <tr>
          <td width="20%">
            培训班名称
          </td>
          <td colspan="3">
            <input
              type="text"
              style="width:100%"
              v-model="dataForm.className"
            />
          </td>
        </tr>
        <tr>
          <td width="20%">
            任课教师姓名
          </td>
          <td width="28%">
            <input type="text" style="width:100%" v-model="dataForm.rkjsxm" />
          </td>
          <td width="17%">课程名称</td>
          <td>
            <input type="text" style="width:100%" v-model="dataForm.kcmc" />
          </td>
        </tr>
        <tr>
          <td>
            授课地点(教室)
          </td>
          <td>
            <input type="text" style="width:100%" v-model="dataForm.skdd" />
          </td>
          <td>授课方式</td>
          <td>
            <input type="text" style="width:100%" v-model="dataForm.skfs" />
          </td>
        </tr>
        <tr>
          <td>
            授课时间
          </td>
          <td>
            <input type="text" style="width:100%" v-model="dataForm.sksj" />
          </td>
          <td colspan="2" style="text-align: left">
            <div class="bomlabel_date">
              <span style="margin:0"
                >学员人数：
                <input
                  type="text"
                  style="width:30%"
                  v-model="dataForm.rs"
                  oninput="value=value.replace(/^(0+)|[^\d]+/g,'')"
              /></span>
              <span style="margin:0"
                >实到：
                <input
                  type="text"
                  style="width:30%"
                  v-model="dataForm.sd"
                  oninput="value=value.replace(/^(0+)|[^\d]+/g,'')"
              /></span>
              <span style="margin:0"
                >缺勤：
                <input
                  type="text"
                  style="width:30%"
                  v-model="dataForm.qq"
                  oninput="value=value.replace(/^(0+)|[^\d]+/g,'')"
              /></span>
            </div>
          </td>
        </tr>
        <tr height="325px">
          <td colspan="4">
            <div
              style="text-align: left; vertical-align: top; height: 325px;"
              valign="top"
            >
              教师课堂授课图片张贴处：
            </div>
          </td>
        </tr>
        <tr height="130px">
          <td colspan="4" style="text-align:right">
            <div style="margin-top:50px">
              <div style="margin-right:20px">
                <span> 班主任(签名)：</span
                ><input type="text" v-model="dataForm.bzr" width="70%" />
              </div>
              <div>
                <span
                  >日期：
                  <el-date-picker
                    v-model="rq"
                    type="date"
                    value-format="yyyy-MM-dd"
                    size="mini"
                    style="width:20%"
                  >
                  </el-date-picker>
                </span>
                <!-- <span
                  ><input
                    class="YMDdate"
                    type="text"
                    v-model="dataForm.year"
                    style="width:5%"
                    oninput="value=value.replace(/^(0+)|[^\d]+/g,'')"
                  />年</span
                >
                <span
                  ><input
                    class="YMDdate"
                    type="text"
                    v-model="dataForm.month"
                    oninput="value=value.replace(/^(0+)|[^\d]+/g,'')"
                    style="width:3%"
                  />月</span
                >
                <span
                  ><input
                    class="YMDdate"
                    type="text"
                    v-model="dataForm.day"
                    oninput="value=value.replace(/^(0+)|[^\d]+/g,'')"
                    style="width:3%"
                  />日</span
                >-->
              </div>
            </div>
          </td>
        </tr>
      </table>

      <div class="table_bottom">
        注：教师课堂授课图片须为教师与学员同框。 授课时间注明日期和起止时间。
      </div>
    </div>
  </div>
</template>
<script>
import request from "@/utils/request";
export default {
  name: "TISchedule",
  data() {
    return {
      loading: true,
      dataForm: {},
      list: [],
      rq: ""
    };
  },
  created() {},
  methods: {
    init(id) {
      this.loading = true;
      request({
        url: "/api/class_archives/generateA7/" + id+`?organizeId=${this.$store.getters.organizeId}`,
        method: "get"
      }).then(res => {
        this.dataForm = res.data;
        this.loading = false;
      });
    },
    exportWord() {
      let rqArr = this.rq.split("-");
      this.dataForm.year = rqArr[0];
      this.dataForm.month = rqArr[1];
      this.dataForm.day = rqArr[2];
      for (let key in this.dataForm) {
        if (this.dataForm[key] == null) {
          this.dataForm[key] = "";
        }
      }
      this.dataForm.organizeId = this.$store.getters.organizeId;
      request({
        responseType: "blob",
        url: "/api/class_archives/generateA7Export",
        method: "post",
        data: this.dataForm
      }).then(res => {
        var debug = res;
        if (debug) {
          var a = document.createElement("a");
          a.download = "培训日志表.docx";
          a.style.display = "none";
          var blob = new Blob([debug], { type: "application/x-msdownload" });
          a.href = URL.createObjectURL(blob);
          document.body.appendChild(a);
          a.click();
          document.body.removeChild(a);
        }
      });
    }
  }
};
</script>
<style scoped lang="scss">
// 引入公共样式
@import "./TABLESTYLE.scss";
</style>
